package io.geekidea.boot.baiwang.service.impl;

import com.baiwang.open.entity.request.node.ImageInvoicesRecogcollectFileBase64Info;
import io.geekidea.boot.baiwang.dto.RecogcollectRequest;
import io.geekidea.boot.baiwang.dto.common.Result;
import io.geekidea.boot.baiwang.service.RecogcollectService;
import io.geekidea.boot.util.baiwangApi.Recogcollect;
import io.geekidea.boot.util.Base.ObtainNameAndBase64;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Slf4j
@Service
public class RecogcollectServiceImpl implements RecogcollectService {
    @Resource
    private ObtainNameAndBase64 obtainNameAndBase64;

    /**
     * 发票验真
     *
     * @param recogcollectRequest
     * @throws Exception
     */
    @Override
    public Result recogcollectDataByInstanceId(RecogcollectRequest recogcollectRequest) {
        List<ImageInvoicesRecogcollectFileBase64Info> filesMap;
        // 获取文件名称和Base64编码
        try {
            filesMap= obtainNameAndBase64.getFlieBaseAndName(recogcollectRequest.getInstanceId());
        } catch (Exception e) {
            return Result.error(e.getMessage());
        }
        //TODO 调用发票验真接口
        Recogcollect.recogcollectInvoice(filesMap);
        return null;
    }
}
